Introduction to Time Series Analysis - 02
This note is for course MATH 545 at McGill University.
Lecture 4 - Lecture 6
We recommend an R package named “forecast”.
First order Autoregressive process AR(1)
Assume {Xt} is a sequence of random variables that is stationary, satisfying Xt=ϕXt−1+Zt, for t=0,±1,±2,..., where {Zt} is a White Noise process of WN(0,σ2), and {Zt} is uncorrelated with {Xt} for ∀s<t, and ϕ is a real-valued constant.
(Graphical representation will be added later)
We have E(Xt)=ϕE(Xt−1)+E(Zt)=ϕμX+0.
By assuming {Xt} is stationary, we need μX=0 (or ϕ=1 or ϕ=0)
By construction, (Xt−h)Xt=(Xt−h)(Xt−1+Zt)
Take expectation, E(Xt−hXt)=E(Xt−h(Xt−1+Zt))
E(Xt−hXt)=ϕE(Xt−hXt−1)+E(Xt−hZt)=ϕE(Xt−hXt−1)
Then we have γX(h)=ϕγX(h−1)=ϕ[ϕγX(h−2)]=...=ϕhγX(0), and ρX(h)=γX(0)γX(h)=ϕh.
By symmetry and stationary, we have ρX(h)=ϕ∣h∣
γX(0)=Cov(Xt,Xt)=E((ϕXt−1+Zt)(ϕXt−1+Zt))=ϕ2E(Xt−12)+E(Zt2)=ϕ2γX(0)+σ2 (as Xt−1 and Zt are not correlated by definition)
Therefore, we have γX(0)=1−ϕ2σ2 with ∣ϕ∣<1.
Estimating Autocorrelation
Let X1,...,Xn be observed values for a stationary sequence, and sample mean Xˉ=n1∑i=1nXi.
We have covariance Cov(V,W)=E[(V−E(V))(W−E(W))], and the unbiased estimator of covariance as Cov^(V,W)=n−1∑i=1n(Vi−Vˉ)(Wi−Wˉ)
γX(h)=Cov(Xt+h,Xt)
γ^X(h)=n1∑t=1n−∣h∣(Xt+∣h∣−Xˉ)(Xt−Xˉ) for −n<h<n
The sample autocorrelation ρ^(h)=γX(0)γ^X(h), where γX(0)=n1∑t=1n(Xt−Xˉ)2.
Classical Decomposition Model
Xt=mt+St+Yt
mt here shows “trend”, St shows seasonal patterns, and Yt is random “noise” component (so far we have 4 choices of noise: iid, white noise, MA(1), and AR(1))
We can remove mt and St to estimate Yt, and we have two ways:
- estimate trend/seasonal using a “model” (filter)
- differencing {Xt} to estimate trend and seasonality (filter)
Estimate Trend
Xt=mt+Yt,t=1,...,n, and E(Yt)=0
We can use Nonparametric methods, which is flexible and with fewer assumptions, but is subjective
- Finite Moving Average Filter (to capture local trend)
Wt=2q+11∑j=−qqXt−j=2q+11∑j=−qq(mt−j+Yt−j)=2q+11[∑j=−qqmt−j]+2q+11[∑j=−qqYt−j]≈2q+11∑j=−qqmt−j where q is a positive integer
Moving Average is a linear filter where aj={2q+11,for∣j∣≤q0,otherwise
Our goal is Xt−m^t=Y^t
- Exponential smoothing
m^t=αXt+(1−α)m^t−1
For t=1, we have m^1=X1. For t≥2, m^t=∑j=0t−2α(1−α)jXt−j+(1−α)t−1X1.
- Parametric smoothing (linear, polynomial, basic function b-spline)
- High-frequency smoothing using Fourier Series
Differencing(for trend)
We define the lag-1 difference as ∇Xt=Xt−Xt−1=(1−B)Xt, where B is known as the backwards shift operator with BXt=Xt−1
We can generalize ∇ and B to general lags by taking powers:
BjXt=Bj−1(BXt)=Bj−1Xt−1=...=Xt−j
Xt−Xt−j=(1−Bj)Xt
As ∇jXt=∇(∇j−1Xt), we have:
∇2Xt=∇(∇Xt)=∇((1−B)Xt)=(1B)(1−B)Xt=(1−2B+B2)Xt=Xt−2BXt+B2Xt=Xt−2Xt−1+Xt−2=(Xt−Xt−1)−(Xt−1−Xt−2)
Let Xt=mt+Yt, where mt=a+bt, we have
∇Xt=∇(mt+Yt)=∇mt+∇Yt=mt−mt−1+Yt−Yt−1=(a+bt)+(a+b(t−1))+Yt−Yt−1=b+Yt−Yt−1
Therefore we could say ∇Xt will be stationary if Yt−Yt−1 is stationary.
Estimate seasonal component
An example of d=4
k=1 |
k=2 |
k=3 |
k=4 |
|
x~1 |
x~2 |
x~3 |
x~4 |
→j=0 |
x~5 |
x~6 |
x~7 |
x~8 |
→j=1 |
x~9 |
x~10 |
x~11 |
x~12 |
→j=2 |
↓ |
↓ |
↓ |
↓ |
|
S1 |
S2 |
S3 |
S4 |
|
Wk=∑j=1t/d−1(Xk+jd−m^k+jd)
S^k=Wk−d1∑i=1dWi
Let dt=Xt−S^t as deseasonal data, we can reestimate the trend from dt and m~t by Y^t=Xt−S^t−m~t
Differencing (for seasonal)
∇dXt=Xt−Xt−d=(1−Bd)Xt
Apply this to Xt=mt+St+Yt, we have:
∇dXt=∇d(mt+St+Yt)=(mt−mt−d)+(St−St−d)+(Yt−Yt−d)
Therefore X~t=(mt−mt−d)+(Yt−Yt−d)
If mt=a+bt, X~t=((a+bt)−(a+b(t−d)))+(Yt−Yt−d)=bd+(Yt−Yt−d)
If Yt∼ iid (0,σ2), we have \hat{p}(h) \stackrel{\text { · }}{\sim} N\left(0, \frac{1}{n}\right). (No proof)
(Recall that p^(h)=γ^(0)γ^(h)=∑i=1n(Xi−Xˉ)2/n∑i=1n−∣h∣(Xi−Xˉ)(Xi+n−Xˉ)/n)